import request from '@/utils/request.js'

// 请求文章
export const getArticleDetailAPI = id => {
  return request.get(`/v1_0/articles/${id}`)
}

// 关注用户的API
export const followUserAPI = (userId) => {
  return request.post('/v1_0/user/followings', {
    target: userId
  })
}

// 取关用户
export const unfollowUserAPI = (userId) => {
  return request.delete(`/v1_0/user/followings/${userId}`)
}

// 点赞文章
export const addLikeAPI = (artId) => {
  return request.post('/v1_0/article/likings', {
    target: artId
  })
}

// 取消点赞
export const delLikeAPI = (artId) => {
  return request.delete(`/v1_0/article/likings/${artId}`)
}

// 评论列表
export const getCmtListAPI = (artId, offset) => {
  return request.get('/v1_0/comments', {
    params: {
      type: 'a',
      source: artId,
      offset
    }
  })
}

// 评论点赞
export const addLikeCmtAPI = (cmtId) => {
  return request.post('/v1_0/comment/likings', {
    target: cmtId
  })
}

// 评论取消点赞
export const delLikeCmtAPI = (cmtId) => {
  return request.delete(`/v1_0/comment/likings/${cmtId}`)
}

// 发表评论
export const pubCommentAPI = (artId, content) => {
  return request.post('/v1_0/comments', {
    target: artId,
    content
  })
}
